package org.geek4j.thirty.percent.persistence.domain;

import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.geek4j.base.persistence.entity.BaseEntity;

import lombok.Getter;
import lombok.Setter;

/**
 * @author Geek4J
 * @since 2016年4月9日 上午11:00:19
 * @description CaptchaController
 */
@Entity
@Table(name = "category")
@Setter
@Getter
public class Category extends BaseEntity {

	private static final long serialVersionUID = -8442783019525438424L;

	/* 分类名称 */
	@Column(name = "name", length = 500)
	private String name;

	/* 父级分类 */
	@Column(name = "parent_id", length = 11)
	private Integer parentId;

	/* 状态 0 正常 1 删除 */
	@Column(name = "status", length = 1)
	private Integer status;

	/* 顶级分类默认值为1 次级分类依次递增 */
	@Column(name = "level", length = 11)
	private Integer level;

	/* 状态 0 正常 1 删除 */
	@Column(name = "icon_path", length = 255)
	private String iconPath;

	/* 关联父级分类 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "parent_id", insertable = false, updatable = false)
	private Category parentCategory;

	/* 关联子级分类 */
	@OneToMany(mappedBy = "parentCategory", fetch = FetchType.LAZY)
	private Set<Category> childCategories;
}